<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 流年 <liu21st@gmail.com>
// +----------------------------------------------------------------------

// 应用公共文件



/**
 * 补全链接
 * @param string $content 需要处理的相对链接
 * @param string $siteUrl 网站网址
 * @param string $url 其为数组时，是Multi的成功时的回调函数参数；否则，是当前的网址链接
 * @return string
 */
function absolute_url($content, $siteUrl, $url){
    $siteUrl = rtrim($siteUrl,'/');
    $baseUrl = '';
    if(!strstr($content,'http')){
        if(substr($content,0,1) != '/'){
            $i = strrpos($url,'/');
            $baseUrl = $i === false ?  '/' : substr($url,0,$i+1);
        }
        $content = $baseUrl . $content;
    }
    return strstr($content,'http') ? $content : $siteUrl . $content ;
}

function convertUrlQuery($query)
{
    $queryParts = explode('&', $query);

    $params = array();
    foreach ($queryParts as $param)
    {
        $item = explode('=', $param);
        $params[$item[0]] = $item[1];
    }

    return $params;
}